﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MudEngine.Parsing.AST
{
    public class InvocationExpression : Expression
    {
        public string FunctionName { get; private set; }

        public Expression Target { get; private set; }

		public List<Expression> Arguments { get; private set; }

        public InvocationType CallType { get; private set; }
		
        public InvocationExpression(Expression target)
        {
			this.Target = target; this.Target.Parent = this;
			this.Arguments = new List<Expression>();
            this.CallType = InvocationType.CALL_FUNCTION;
        }

        public InvocationExpression(Expression target, string functionName, InvocationType callType)
            : this(target)
        {
            this.FunctionName = functionName;
            this.CallType = callType;
        }

		public void AddArgument(Expression e)
		{
			this.Arguments.Add(e);
		}

        public override void AcceptVisitor<C>(IAstNodeVisitor<C> visitor, C ctx)
        {
            visitor.VisitInvocationExpression(this, ctx);
        }
    }

    public enum InvocationType
    {
        CALL_OTHER,
        CALL_INHERITED,
        CALL_FUNCTION
    }
}
